﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.PackageManagement;
using Digitalmes.Model.ProductManagement;
using Digitalmes.Model.PlanningManagement;

namespace Digitalmes.Model.PackageManagement
{
    /// <summary>
    /// 装箱
    /// </summary>
	[Table("PackageBank")]

    [Display(Name = "_Model.PackageBank")]
    public class PackageBank : TopBasePoco,IPersistPoco,ITenant
    {
        [Key]
        [Display(Name = "_Model._PackageBank._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }
        [Display(Name = "_Model._PackageBank._Sn")]
        [Comment("装箱条码")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string Sn { get; set; }
        [Display(Name = "_Model._PackageBank._ProductId")]
        [Comment("装箱产品")]
        public long? ProductId { get; set; }

        public Product Product { get; set; }


        [Display(Name = "_Model._PackageBank._ProductName")]
        [Comment("产品名称")]
        public string ProductName { get; set; }
        [Display(Name = "_Model._PackageBank._StartTime")]
        [Comment("首次装箱时间")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public DateTime? StartTime { get; set; }
        [Display(Name = "_Model._PackageBank._LastTime")]
        [Comment("最后装箱时间")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string LastTime { get; set; }
        [Display(Name = "_Model._PackageBank._CurrentCount")]
        [Comment("当前装箱数量")]
        [Precision(18,2)]
        [Required(ErrorMessage = "Validate.{0}required")]
        public decimal? CurrentCount { get; set; }
        [Display(Name = "_Model._PackageBank._Qty")]
        [Comment("可装数量")]
        [Precision(18,2)]
        [Required(ErrorMessage = "Validate.{0}required")]
        public decimal? Qty { get; set; }
        [Display(Name = "_Model._PackageBank._LastSn")]
        [Comment("最后零件条码")]
        public string LastSn { get; set; }
        [Display(Name = "_Model._PackageBank._WoId")]
        [Comment("工单")]
        public long? WoId { get; set; }

        public  ProductionOrder Wo { get; set; }    


        [Display(Name = "_Model._PackageBank._WoCode")]
        [Comment("工单编码")]
        public string WoCode { get; set; }
        [Display(Name = "_Model._PackageRecord._Package")]
        [InverseProperty("Package")]
        public List<PackageRecord> PackageRecord_Package { get; set; }
        [Display(Name = "_Model._PackageBank._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
